package com.jake.rabbit.consumer;

import lombok.Getter;
import lombok.Setter;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.Map;

import static com.jake.common.constant.QueueConstants.RESPONSE_QUEUE;

@Component
@RabbitListener(queues = {RESPONSE_QUEUE + 1, RESPONSE_QUEUE + 2,
                RESPONSE_QUEUE + 3, RESPONSE_QUEUE + 4, RESPONSE_QUEUE + 5})
public class ResponseMapConsumer {

    @Getter
    @Setter
    private Map<String, Object> responseMap;

    @RabbitHandler
    public void listenResponseMap(Map<String, Object> responseMap) {
        if (!CollectionUtils.isEmpty(responseMap)) {
            setResponseMap(responseMap);
        }
    }

}
